{% extends 'PHPDishWebBundle::layout.html.twig' %}

{% set title = topic is defined ? '编辑话题' : '创建新话题' %}

{% block title %}
    {{ title }}
{% endblock %}

{% block script %}
    <script type="text/javascript" src="{{ asset('build/js/topic.js') }}"></script>
{% endblock %}

{% block content %}
    <div class="container" role="main">
        <div class="row">
            <article class="col-md-9">
                <div class="panel panel-u add-topic">
                    <div class="panel-heading">
                        {{ title }}
                    </div>
                    <div class="panel-body">
                        {{ form_start(form, {'attr': {'id': 'add-topic-form', 'class': 'topic'}}) }}
                        {{ form_errors(form) }}
                        <div class="form-group">
                            {{ form_widget(form.title, {'attr': {'class': 'form-control title', placeholder: '请填写标题'}}) }}
                            {{ form_errors(form.title) }}
                        </div>
                        <div class="form-group editor">
                            {{ form_widget(form.originalBody, {'required': false, 'attr': {'class': 'form-control body', placeholder: '请填写正文，支持Markdown，注意排版与代码高亮'}}) }}
                            {{ form_errors(form.originalBody) }}
                        </div>
                        <div class="form-group">
                            {{ form_widget(form.thread, {'attr': {'class': 'selectpicker thread'}}) }}
                            {{ form_errors(form.thread) }}
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn u-btn-primary submit-btn"><i class="if i-publish"></i> 发布</button>
                            <span class="preview-action" data-action="preview"><i class="if i-view"></i> 预览</span>
                        </div>
                        {{ form_end(form) }}
                        <div class="preview-panel markdown-body hidden" data-role="preview-panel">
                            预览区域
                        </div>
                    </div>
                </div>
            </article>
            <div class="col-md-3">
                {% include 'PHPDishWebBundle:User:user_plate.html.twig' %}
            </div>
        </div>
    </div>
{% endblock %}